<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" type="text/css" href="css/style-min.css" />
<link rel="stylesheet" type="text/css" href="css/table-min.css" />
<link rel="stylesheet" type="text/css" href="css/menu-min.css" />
</head>
<body>
<?php    /*XX-XX-X-XXX-001*/
	/*SELECT COUNT(*) as "jumlah" FROM login WHERE mid(no_reg,1,2)='15' and mid(no_reg,7,1)='1'*/
		
    /*session_start();
		
    ob_start();*/
	
    $data=$_GET["q"];
    $sprop2 = $_GET["prop"];
    $skab = $_GET["kab"];
    $ikab2 = (int)$skab;
    $iprop_sel= (int)$sprop2;
    $reg_anggota = $_GET["anggota"];
    $tipe_kk = $_GET["tipe_kk"];
    $sdaerah = $_GET["daerah"];
    //echo $data2;
    include('class.mysql.php');
    $mydb = new mysql();
    $connection = $mydb->Connect();
    
    //$jml_kkg[];
    //$jml_mgmp[];
    //$jml_kksk[];
    //$jml_mkks[];
    //$jml_kkps[];
    //$jml_mkps[];
    //echo $iprop_sel;

    if(1)
    {
	$stTemp = '<table class="box" align="center">'.'<tbody><tr>'.'<th rowspan="2">Nama Kelompok Kerja</th>'.'<th colspan="6">Ringkasan Data Kelompok Kerja</th>'.'</tr><tr>';
	$stTemp .= '<th>No Registrasi</th><th>Propinsi</th><th>Kab / Kota</th><th>Jenis KK</th><th>Kecamatan</th></tr>';
	$sql="SELECT nama_kk,no_reg,kecamatan FROM identitas WHERE mid(no_reg,7,1) like '$tipe_kk%' and mid(no_reg,1,2) = '$sprop2' and mid(no_reg,4,2) like '$skab%' and daerah like '$sdaerah%' order by mid(no_reg,1,5),mid(no_reg,13,3)";
	//echo "$sql";	
	$query = $mydb->Query($sql);
	$num = $mydb->FetchNum($query);
	
	//$kabupaten[]="Pilih kota2";
	$urut=1;
	while($array= mysql_fetch_row($query))
	{
	    $nama_kk2=$array[0];
	    $no_reg2=$array[1];
	    $kecamatan2=$array[2];
	    /*Mengambil nama propinsi*/
            $sprop = substr($no_reg2,0,2);
            $skab2 = substr($no_reg2,3,2);
            $sql2="SELECT propinsi FROM propinsi where kode='$sprop'";
            //echo "$sql2";	
            $query2 = $mydb->Query($sql2);
            $num2 = $mydb->FetchNum($query2);
            if($array2= mysql_fetch_row($query2))
            {
	         $nama_prop=$array2[0];
            }
            //end
	    /*Mengambil nama kabupaten*/
            $sprop = substr($no_reg2,0,2);
            $skab2 = substr($no_reg2,3,2);
            $sql2="SELECT kabupaten FROM kabupaten where kode_prop = '$sprop' and kode='$skab2'";
            //echo "$sql2";	
            $query2 = $mydb->Query($sql2);
            $num2 = $mydb->FetchNum($query2);
            if($array2= mysql_fetch_row($query2))
            {
	         $nama_kab=$array2[0];
            }
            //end
            
	    if (substr($no_reg2,6,1)=='1')
		$jenis_kk='KKG';
	    else if (substr($no_reg2,6,1)=='2')
	        $jenis_kk ='MGMP';
	    else if (substr($no_reg2,6,1)=='3')
	        $jenis_kk ='KKKS';
	    else if (substr($no_reg2,6,1)=='4')
	        $jenis_kk ='MKKS';
	    else if (substr($no_reg2,6,1)=='5')
	        $jenis_kk ='KKPS';
	    else if (substr($no_reg2,6,1)=='6')
	        $jenis_kk ='MKPS';
	    //echo substr($no_reg2,6,1);
	    $ln_tampil='view.php?reg='.$no_reg2;
	    $stTemp .= '<tr><td nowrap=""><a href='.$ln_tampil.'>'.(string)$urut.' - '.$nama_kk2.'</a></td>';
	    $stTemp .= '<td align="center">'.$no_reg2.'</td>';
	    $stTemp .= '<td align="center">'.$nama_prop.'</td>';
	    $stTemp .= '<td align="center">'.$nama_kab.'</td>';
	    $stTemp .= '<td align="center">'.$jenis_kk.'</td>';
	    $stTemp .= '<td align="center">'.$kecamatan2.'</td></tr>';
	    $urut=$urut+1;
	    echo    $stTemp;
	    $stTemp="";
	}
	$stTemp="";
	if ($no_reg2=='')
	{
	    $stTemp .= '<tr><td align="center"> Data tidak ditemukan</td>';
	    $stTemp .= '<td align="center"> </td>';
	    $stTemp .= '<td align="center"> </td>';
	    $stTemp .= '<td align="center"> </td>';
	    $stTemp .= '<td align="center"> </td>';
	    $stTemp .= '<td align="center"> </td><tr>';
	}
	echo    $stTemp;
    	
    }

?>

<!--<table class="box" align="center">
	<tbody><tr>
		<th rowspan="2">Propinsi</th>
		<th colspan="6">Kelompok Kerja</th>
	</tr>
	<tr>
		<th>KKG</th>
		<th>MGMP</th>
		<th>KKKS</th>
		<th>MKKS</th>
		<th>KKPS</th>
		<th>MKPS</th>
	</tr>
		<tr>
		<td nowrap="">2010/2011 - 3</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>

	</tr>
		<tr>
		<td nowrap="">2010/2011 - 3</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>

	</tr>
		<tr>
		<td nowrap="">2010/2011 - 3</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>

	</tr>
		<tr>
		<td nowrap="">2010/2011 - 3</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>

	</tr>
		<tr>
		<td nowrap="">2010/2011 - 3</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>

	</tr>
		<tr>
		<td nowrap="">2010/2011 - 3</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>
		<td align="center">0</td>

	</tr>
	</tbody></table>-->
</body>